package cn.com.css.taxInspection.workrisk.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.aspectj.weaver.ArrayAnnotationValue;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import cn.com.css.taxInspection.common.aop.annotation.LogAnnotation;
import cn.com.css.taxInspection.common.constants.Constants;
import cn.com.css.taxInspection.common.result.DataResult;
import cn.com.css.taxInspection.gt3.entity.DmGySwjgEntity;
import cn.com.css.taxInspection.gt3.entity.DmQxSwrysfEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjxxEntity;
import cn.com.css.taxInspection.gt3.entity.JcJcryEntity;
import cn.com.css.taxInspection.gt3.service.DmGySwjgService;
import cn.com.css.taxInspection.gt3.service.DmQxSwrysfService;
import cn.com.css.taxInspection.gt3.service.JcAjxxService;
import cn.com.css.taxInspection.gt3.service.JcJcryService;
import cn.com.css.taxInspection.system.entity.SysUser;
import cn.com.css.taxInspection.system.entity.SysUserRole;
import cn.com.css.taxInspection.system.mapper.SysUserRoleMapper;
import cn.com.css.taxInspection.system.service.UserService;
import cn.com.css.taxInspection.system.service.impl.HttpSessionService;
import cn.com.css.taxInspection.util.TsBqUtils;
import cn.com.css.taxInspection.workflow.constants.WorkflowConstants;
import cn.com.css.taxInspection.workrisk.entity.WorkriskControlDispatchEntity;
import cn.com.css.taxInspection.workrisk.entity.WorkriskControlEntity;
import cn.com.css.taxInspection.workrisk.entity.WorkriskRisk1Entity;
import cn.com.css.taxInspection.workrisk.service.WorkriskControlDispatchService;
import cn.com.css.taxInspection.workrisk.service.WorkriskControlService;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * ${comments}
 *
 * @author shaochangyang
 * @email l2l84o7o5@live.com
 * @date 2023-10-18 10:03:49
 */
@Controller
@RequestMapping("/workflow/control")
public class WorkriskControlController {
	@Autowired
	private WorkriskControlService workriskControlService;
	@Autowired
	private HttpSessionService httpSessionService;
	@Autowired
	private JcAjxxService jcAjxxService;
	@Autowired
	private DmGySwjgService dmGySwjgService;
	@Autowired
	private UserService userService;
	@Autowired
	private SysUserRoleMapper sysUserRoleMapper;
	@Autowired
	private DmQxSwrysfService dmQxSwrysfService;
	@Autowired
	private JcJcryService jcJcryService;
	@Autowired
	private WorkriskControlDispatchService workriskControlDispatchService;
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "督办-个人未处理列表")
	@PostMapping("/unheallist1")
	@RequiresPermissions("workflow:control:unheallist1")
	@ResponseBody
	@LogAnnotation(title = "督办", action = "个人未处理列表")
	public DataResult unheallist1(@RequestBody WorkriskControlEntity workriskControl) {
		
		String currentRolesId = httpSessionService.getCurrentRolesId();
		String currentDeptId = httpSessionService.getCurrentDeptId();
		// 1717361227428265985	日志-纪检岗
		// 1708113663597502466	检查-检查科科长岗位
		
        boolean status1 = currentRolesId.contains("1717361227428265985");
        boolean status2 = currentRolesId.contains("1708113663597502466");
        
		String currentUserId = httpSessionService.getCurrentUserId();
		Page page = new Page(workriskControl.getPage(), workriskControl.getLimit());
		LambdaQueryWrapper<WorkriskControlEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		
		if(status1){
			// 日志-纪检岗
			queryWrapper.like(WorkriskControlEntity::getControlMan1, "1717361227428265985");
			queryWrapper.eq(WorkriskControlEntity::getTaxorgcode, currentDeptId);
			
		}else if(status2){
			// 检查-检查科科长岗位
			queryWrapper.like(WorkriskControlEntity::getControlMan1, "1708113663597502466");
			queryWrapper.eq(WorkriskControlEntity::getTaxorgcode, currentDeptId);
			// queryWrapper.isNull(WorkriskControlEntity::getControlRead1);
			
		}else{
			// 检查人
			queryWrapper.like(WorkriskControlEntity::getControlMan1, currentUserId);
			
		}
		List<String> neList = new ArrayList<String>();
		neList.add("3");
		neList.add("99");
		queryWrapper.notIn(WorkriskControlEntity::getStateCode, neList);
		
		IPage<WorkriskControlEntity> iPage = workriskControlService.page(page, queryWrapper);

		List<WorkriskControlEntity> records = iPage.getRecords();

		for (WorkriskControlEntity workriskControlEntity : records) {
			String relevance = workriskControlEntity.getRelevance();
			String controlName = workriskControlEntity.getControlName();
			String details = workriskControlEntity.getDetails();
			String id = workriskControlEntity.getId();
			String stateCode = workriskControlEntity.getStateCode();
			String stateName = workriskControlEntity.getStateName();
			JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
			if(TsBqUtils.isNotNull(jcAjxxEntity)){
				BeanUtils.copyProperties(jcAjxxEntity, workriskControlEntity);
				workriskControlEntity.setControlName(controlName);
				workriskControlEntity.setId(id);
				workriskControlEntity.setDetails(details);
				
			}
			
			workriskControlEntity.setStateCode(stateCode);
			workriskControlEntity.setStateName(stateName);
			
			workriskControlEntity.setPostion(currentRolesId);
		}

		return DataResult.success(iPage);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "内控内生化-个人已读列表")
	@PostMapping("/heallist1")
	@RequiresPermissions("workflow:control:heallist1")
	@ResponseBody
	@LogAnnotation(title = "督办", action = "个人已读列表")
	public DataResult readlist1(@RequestBody WorkriskControlEntity workriskControl) {
		String currentUserId = httpSessionService.getCurrentUserId();
		Page page = new Page(workriskControl.getPage(), workriskControl.getLimit());
		LambdaQueryWrapper<WorkriskControlEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		queryWrapper.like(WorkriskControlEntity::getControlMan1, currentUserId);
		// queryWrapper.isNotNull(WorkriskControlEntity::getControlRead1);
		
		List<String> neList = new ArrayList<String>();
		neList.add("3");
		neList.add("99");
		queryWrapper.in(WorkriskControlEntity::getStateCode, neList);
		
		IPage<WorkriskControlEntity> iPage = workriskControlService.page(page, queryWrapper);

		List<WorkriskControlEntity> records = iPage.getRecords();

		for (WorkriskControlEntity workriskControlEntity : records) {
			String relevance = workriskControlEntity.getRelevance();
			String controlName = workriskControlEntity.getControlName();
			String details = workriskControlEntity.getDetails();
			String id = workriskControlEntity.getId();
			
			JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
			if(TsBqUtils.isNotNull(jcAjxxEntity)){
				BeanUtils.copyProperties(jcAjxxEntity, workriskControlEntity);
				workriskControlEntity.setControlName(controlName);
				workriskControlEntity.setId(id);
				workriskControlEntity.setDetails(details);
				
			}
			
			String controlMan1State = workriskControlEntity.getControlMan1State();
			
			if(TsBqUtils.isNotNull(controlMan1State)){
				
				if(controlMan1State.equals("Y")){
					workriskControlEntity.setControlMan1State("已处理");
				}else if(controlMan1State.equals("N")){
					workriskControlEntity.setControlMan1State("已忽略");
				}
				
			}else{
				workriskControlEntity.setControlMan1State("未处理");
			}
			
		}

		return DataResult.success(iPage);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "内控内生化-科长岗位未读列表")
	@PostMapping("/unheallist2")
	@RequiresPermissions("workflow:control:unheallist2")
	@ResponseBody
	@LogAnnotation(title = "内控内生化", action = "科长岗位未读列表")
	public DataResult unreadlist2(@RequestBody WorkriskControlEntity workriskControl) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Page page = new Page(workriskControl.getPage(), workriskControl.getLimit());
		LambdaQueryWrapper<WorkriskControlEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		queryWrapper.eq(WorkriskControlEntity::getTaxorgcode, currentDeptId);
		queryWrapper.isNotNull(WorkriskControlEntity::getControlMan2);
		
		queryWrapper.isNull(WorkriskControlEntity::getControlRead2);
		
		IPage<WorkriskControlEntity> iPage = workriskControlService.page(page, queryWrapper);

		List<WorkriskControlEntity> records = iPage.getRecords();

		for (WorkriskControlEntity workriskRisk1Entity : records) {
			String relevance = workriskRisk1Entity.getRelevance();
			String controlName = workriskRisk1Entity.getControlName();
			
			JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
			BeanUtils.copyProperties(jcAjxxEntity, workriskRisk1Entity);
			jcAjxxEntity.setControlName(controlName);

		}

		return DataResult.success(iPage);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "内控内生化-科长岗位已读列表")
	@PostMapping("/heallist2")
	@RequiresPermissions("workflow:control:heallist2")
	@ResponseBody
	@LogAnnotation(title = "内控内生化", action = "科长岗位已读列表")
	public DataResult readlist2(@RequestBody WorkriskControlEntity workriskControl) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		Page page = new Page(workriskControl.getPage(), workriskControl.getLimit());
		LambdaQueryWrapper<WorkriskControlEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		queryWrapper.eq(WorkriskControlEntity::getTaxorgcode, currentDeptId);
		queryWrapper.isNotNull(WorkriskControlEntity::getControlRead2);
		queryWrapper.isNotNull(WorkriskControlEntity::getControlMan2);
		
		IPage<WorkriskControlEntity> iPage = workriskControlService.page(page, queryWrapper);

		List<WorkriskControlEntity> records = iPage.getRecords();

		for (WorkriskControlEntity workriskRisk1Entity : records) {
			String relevance = workriskRisk1Entity.getRelevance();
			String controlName = workriskRisk1Entity.getControlName();
			
			JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
			BeanUtils.copyProperties(jcAjxxEntity, workriskRisk1Entity);
			jcAjxxEntity.setControlName(controlName);

		}

		return DataResult.success(iPage);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "内控内生化-局长岗未读列表")
	@PostMapping("/unheallist3")
	@RequiresPermissions("workflow:control:unheallist3")
	@ResponseBody
	@LogAnnotation(title = "内控内生化", action = "局长岗未读列表")
	public DataResult unreadlist3(@RequestBody WorkriskControlEntity workriskControl) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		Page page = new Page(workriskControl.getPage(), workriskControl.getLimit());
		LambdaQueryWrapper<WorkriskControlEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		queryWrapper.like(WorkriskControlEntity::getTaxorgcode, currentDeptId.substring(0, 9));
		queryWrapper.isNull(WorkriskControlEntity::getControlRead3);
		queryWrapper.isNotNull(WorkriskControlEntity::getControlMan3);
		
		IPage<WorkriskControlEntity> iPage = workriskControlService.page(page, queryWrapper);

		List<WorkriskControlEntity> records = iPage.getRecords();

		for (WorkriskControlEntity workriskRisk1Entity : records) {
			String relevance = workriskRisk1Entity.getRelevance();
			String controlName = workriskRisk1Entity.getControlName();
			
			JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
			BeanUtils.copyProperties(jcAjxxEntity, workriskRisk1Entity);
			jcAjxxEntity.setControlName(controlName);

		}

		return DataResult.success(iPage);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "内控内生化-局长岗位已读列表")
	@PostMapping("/heallist3")
	@RequiresPermissions("workflow:control:heallist3")
	@ResponseBody
	@LogAnnotation(title = "内控内生化", action = "局长岗位已读列表")
	public DataResult readlist3(@RequestBody WorkriskControlEntity workriskControl) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		Page page = new Page(workriskControl.getPage(), workriskControl.getLimit());
		LambdaQueryWrapper<WorkriskControlEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		queryWrapper.like(WorkriskControlEntity::getTaxorgcode, currentDeptId.substring(0, 9));
		queryWrapper.isNotNull(WorkriskControlEntity::getControlRead3);
		queryWrapper.isNotNull(WorkriskControlEntity::getControlMan3);
		
		IPage<WorkriskControlEntity> iPage = workriskControlService.page(page, queryWrapper);
		List<WorkriskControlEntity> records = iPage.getRecords();

		for (WorkriskControlEntity workriskRisk1Entity : records) {
			String relevance = workriskRisk1Entity.getRelevance();
			String controlName = workriskRisk1Entity.getControlName();
			
			JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
			BeanUtils.copyProperties(jcAjxxEntity, workriskRisk1Entity);
			jcAjxxEntity.setControlName(controlName);

		}

		return DataResult.success(iPage);
	}

	@ApiOperation(value = "内控内生化-处理")
	@PostMapping("/head")
	@ResponseBody
	@LogAnnotation(title = "内控内生化", action = "处理")
	public DataResult read(@RequestBody WorkriskControlEntity workriskControl) {
		
		String jcr = workriskControl.getJcr();
		String jjwy = workriskControl.getJjwy();
		
		String currentUserId = httpSessionService.getCurrentUserId();
		String currentDeptId = httpSessionService.getCurrentDeptId();
		String id = workriskControl.getId();
		if(TsBqUtils.isNull(id)){
			return DataResult.fail("未获取到id");
		}
		
		String controlIs = workriskControl.getControlIs();
		if(TsBqUtils.isNull(controlIs)){
			return DataResult.fail("未获取到controlIs");
		}
		
		String controlContent = workriskControl.getControlContent();
		if(TsBqUtils.isNull(controlContent)){
			return DataResult.fail("未获取到controlContent");
		}
		
		String controlHeal = workriskControl.getControlHeal();
		if(TsBqUtils.isNull(controlHeal)){
			return DataResult.fail("未获取到controlHeal");
		}
		
		WorkriskControlEntity workriskControlEntity = workriskControlService.getById(id);
		
		String details = workriskControlEntity.getDetails();
		String relevance = workriskControlEntity.getRelevance();
		if(details.equals("立案30天未制作稽查报告")){
			
			workriskControlEntity.setStateCode("1");
			workriskControlEntity.setStateName("发起调度会");
			
			// 检查人 纪检委员 科长
			String controlContent2 = jcr+":"+jjwy+":"+currentUserId;
			
			workriskControlEntity.setControlContent2(controlContent2);
			
			workriskControlEntity.setControlMan1State("Y");
			workriskControlEntity.setControlRead1(currentUserId);
			workriskControlEntity.setControlContent1(controlContent);
			
			workriskControlEntity.setUpdateId(currentUserId);
			workriskControlEntity.setUpdateTime(new Date());
			workriskControlService.updateById(workriskControlEntity);
			
			// 写入调度会表
			String[] split = controlContent2.split(":");
			
			List<String> _listswry = Arrays.asList(split);
			for (String _swry : _listswry) {
				WorkriskControlDispatchEntity controlDispatch = new WorkriskControlDispatchEntity();
				String uuid = TsBqUtils.getUUID().toString();
				controlDispatch.setId(uuid);
				controlDispatch.setControlid(id);
				controlDispatch.setJcajuuid(relevance);
				controlDispatch.setStateCode("1");
				
				controlDispatch.setDispatchMan(_swry);
				controlDispatch.setTaxorgcode(currentDeptId);
				controlDispatch.setDeleted(Constants.DATA_NOT_DELETED);
				controlDispatch.setCreateTime(new Date());
				controlDispatch.setCreateId(currentUserId);
				workriskControlDispatchService.save(controlDispatch);
				
			}
			
			return DataResult.success();
			
		}
		
		
		if ("1".equals(controlHeal)) {
			workriskControlEntity.setControlRead1(currentUserId);
			workriskControlEntity.setControlContent1(controlContent);
			if(controlIs.equals("Y")){
				workriskControlEntity.setControlMan1State("Y");
			}else if(controlIs.equals("N")){
				workriskControlEntity.setControlMan1State("N");
			}else{
				return DataResult.fail("controlIs状态代码不正确:"+controlIs);
				
			}
		} else if ("2".equals(controlHeal)) {
			workriskControlEntity.setControlRead2(currentUserId);
			workriskControlEntity.setControlContent2(controlContent);
			if(controlIs.equals("Y")){
				workriskControlEntity.setControlMan2State("Y");
			}else if(controlIs.equals("N")){
				workriskControlEntity.setControlMan2State("N");
			}else{
				return DataResult.fail("controlIs状态代码不正确:"+controlIs);
				
			}
		} else if ("3".equals(controlHeal)) {
			workriskControlEntity.setControlRead3(currentUserId);
			workriskControlEntity.setControlContent3(controlContent);
			if(controlIs.equals("Y")){
				workriskControlEntity.setControlMan2State("Y");
			}else if(controlIs.equals("N")){
				workriskControlEntity.setControlMan2State("N");
			}else{
				return DataResult.fail("controlIs状态代码不正确:"+controlIs);
				
			}
			
		} else {
			return DataResult.fail("入参controlHeal不正确：" + controlHeal);
			
		}
		
		
		workriskControlEntity.setUpdateId(currentUserId);
		workriskControlEntity.setUpdateTime(new Date());
		workriskControlService.updateById(workriskControlEntity);
		
		return DataResult.success();
		
	}

	

	private List<DmQxSwrysfEntity> getUserIdentityByIdentityAndTaxorgcode(String userId, String currentDeptId) {
		// TODO Auto-generated method stub
		return null;
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "督办")
	@PostMapping("/sectionChief")
	@ResponseBody
	@LogAnnotation(title = "督办", action = "科长权限")
	public DataResult sectionChief(@RequestBody WorkriskControlEntity workriskControl) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		String taxorgcode = workriskControl.getTaxorgcode();
		String taxCode = "";
		if(TsBqUtils.isNull(taxorgcode)){
			taxCode = currentDeptId;
		}else{
			taxCode = taxorgcode;
		}
		
		Page page = new Page(workriskControl.getPage(), workriskControl.getLimit());
		LambdaQueryWrapper<WorkriskControlEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		queryWrapper.eq(WorkriskControlEntity::getTaxorgcode, taxCode);
		
		IPage<WorkriskControlEntity> iPage = workriskControlService.page(page, queryWrapper);
		
		List<WorkriskControlEntity> records = iPage.getRecords();

		for (WorkriskControlEntity workriskControlEntity : records) {
			String controlMan1 = workriskControlEntity.getControlMan1();
			String controlMan1State = workriskControlEntity.getControlMan1State();
			SysUser sysUser = userService.getById(controlMan1);
			
			if(TsBqUtils.isNotNull(sysUser)){
				controlMan1 = sysUser.getNickName();
			}
			
			if(TsBqUtils.isNull(controlMan1State)){
				controlMan1State = "未处理";
			}else{
				if(controlMan1State.equals("Y")){
					controlMan1State = "已处理";
				}else if(controlMan1State.equals("N")){
					controlMan1State = "已忽略";
				}
				
			}
			
			workriskControlEntity.setControlMan1(controlMan1);
			workriskControlEntity.setControlMan1State(controlMan1State);
			
		}
		
		return DataResult.success(iPage);
		
	}
	
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "督办")
	@PostMapping("/directorGeneral")
	@ResponseBody
	@LogAnnotation(title = "督办", action = "局长权限")
	public DataResult directorGeneral(@RequestBody WorkriskControlEntity workriskControl) {
		
		String currentDeptId = httpSessionService.getCurrentDeptId();
		DmGySwjgEntity dmGySwjgEntity = dmGySwjgService.getSwjgDm(currentDeptId);
		String sjswjgDm = dmGySwjgEntity.getSjswjgDm();
		
		String taxorgcode = workriskControl.getTaxorgcode();
		String taxCode = "";
		if(TsBqUtils.isNull(taxorgcode)){
			taxCode = sjswjgDm;
		}else{
			taxCode = taxorgcode;
		}
		
		Page page = new Page(workriskControl.getPage(), workriskControl.getLimit());
		
		
		
		QueryWrapper<WorkriskControlEntity> queryWrapper = new QueryWrapper<>();
		LambdaQueryWrapper<WorkriskControlEntity> lambdaQueryWrapper = queryWrapper.select("count(1) AS count,TAXORGCODE as TAXORGCODE").lambda().groupBy(WorkriskControlEntity::getTaxorgcode);
		
		// 查询条件示例
		lambdaQueryWrapper.like(WorkriskControlEntity::getTaxorgcode, taxCode.substring(0, 9));
		
		
		IPage<WorkriskControlEntity> iPage = workriskControlService.page(page, queryWrapper);
		
		List<WorkriskControlEntity> records = iPage.getRecords();

		for (WorkriskControlEntity workriskRisk1Entity : records) {
			String _taxorgcode = workriskRisk1Entity.getTaxorgcode();
			
			DmGySwjgEntity _dmGySwjgEntity = dmGySwjgService.getSwjgDm(_taxorgcode);
			String swjgmc = _dmGySwjgEntity.getSwjgmc();
			
			workriskRisk1Entity.setSwjg_dm(swjgmc);
		}
		
		return DataResult.success(iPage);
		
	}
	
	
	@ApiOperation(value = "预警提醒")
	@PostMapping("/city")
	@ResponseBody
	@LogAnnotation(title = "预警提醒", action = "市局权限")
	public DataResult city(@RequestBody WorkriskRisk1Entity workriskRisk1) {
		
		
		
		return null;
	}
	
	@ApiOperation(value = "督办")
	@PostMapping("/alreadyHandle")
	@ResponseBody
	@LogAnnotation(title = "督办", action = "已处理督办")
	public DataResult alreadyHandle(@RequestBody WorkriskControlEntity workriskControlEntity) {
		Date date = new Date();
		String id = workriskControlEntity.getId();
		String currentUserId = httpSessionService.getCurrentUserId();
		String controlContent = workriskControlEntity.getControlContent();
		
		WorkriskControlEntity workriskControl = workriskControlService.getById(id);
		
		workriskControl.setStateCode("99");
		workriskControl.setStateName("已处理");
		workriskControl.setHandleContent(controlContent);
		
		workriskControl.setUpdateTime(date);
		workriskControl.setUpdateId(currentUserId);
		
		workriskControlService.updateById(workriskControl);
		
		return DataResult.success();
	}
	
	
	@ApiOperation(value = "督办")
	@PostMapping("/loadPost")
	@ResponseBody
	@LogAnnotation(title = "督办", action = "加载岗位人员")
	public DataResult loadPost(@RequestBody WorkriskControlEntity workriskControlEntity) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		String id = workriskControlEntity.getId();
		WorkriskControlEntity workriskControl = workriskControlService.getById(id);
		List<Object> list = new ArrayList<>();
		if(workriskControl.getControlName().equals("一级督办")){
			// 一级督办 加载的人员
			// 加载检查人
			String controlMan1 = workriskControl.getControlMan1();
			String string = Arrays.asList(controlMan1.split(":")).get(0);
			List<String> listJcr = Arrays.asList(string.split(","));
			
			list.add(listJcr);
			
			// 加载纪检委员
			List<String> userIdList = new ArrayList<>();
			LambdaQueryWrapper<SysUserRole> sysUserRoleQueryWrapper = Wrappers.lambdaQuery();
			sysUserRoleQueryWrapper.eq(SysUserRole::getRoleId, "1717361227428265985");
			List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectList(sysUserRoleQueryWrapper);
			for (SysUserRole sysUserRole : sysUserRoleList) {
				String userId = sysUserRole.getUserId();
				userIdList.add(userId);
			}

			if (TsBqUtils.isNull(userIdList)) {
				return DataResult.fail("岗位ID:" + "1717361227428265985" + "，没有配置人员！请联系管理员配置人员！");
			}

			LambdaQueryWrapper<DmQxSwrysfEntity> queryWrapper = Wrappers.lambdaQuery();
			queryWrapper.likeRight(DmQxSwrysfEntity::getSfswjgDm, currentDeptId);
			queryWrapper.eq(DmQxSwrysfEntity::getYxbz, "Y");
			queryWrapper.in(DmQxSwrysfEntity::getSwrysfDm, userIdList);
			List<DmQxSwrysfEntity> _list = dmQxSwrysfService.list(queryWrapper);

			// 过滤 检查人环节-办理 推送检查科科长时 本部分
			List<DmQxSwrysfEntity> listHandle = new ArrayList<>();

			if (id.equals("1717361227428265985")) {
				for (DmQxSwrysfEntity dmQxSwrysfEntity : _list) {
					String sfswjgDm = dmQxSwrysfEntity.getSfswjgDm();
					if (currentDeptId.equals(sfswjgDm)) {
						listHandle.add(dmQxSwrysfEntity);
					}
				}
			} else {
				listHandle = _list;
			}

			list.add(_list);
			
		}
		
		
		return DataResult.success(list);
	}
	
	
}
